package com.headStorm.huimingjie.crc;

import cn.hutool.core.bean.BeanPath;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.io.checksum.CRC16;
import cn.hutool.core.io.checksum.CRC8;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.json.JSONUtil;

/**
 * @author zhangqq
 * @create 2021-11-16 11:21
 **/
public class CRCDemo {

    public static void main(String[] args) {

        char[] chars = "TPUD2wAWB01".toCharArray();
        System.out.println((int)CalculateCrc(chars, 2));

        byte[] content = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
        byte[] sub = ArrayUtil.sub(content, 0, 4);
        byte[] sub2 = ArrayUtil.sub(content, 4, 8);
        byte[] sub3 = ArrayUtil.sub(content, 8, 12);
        for (int i = 0; i < sub.length ; i++) {
            System.out.println(sub[i]);
        }
        CRC16 crc16 = new CRC16();
        //BeanPath beanPath =

    }

    public static char CalculateCrc(char[] cmd, int len){
        char crc;
        int i;
        crc = 0;
        for(i=0; i<len; i++){
            crc += cmd[i];
        }
        return(crc);
    }



}
